import request from '@/utils/request'

// 获取分类树
export function getCategoryTree() {
  return request({
    url: '/category/tree',
    method: 'get'
  })
}

// 获取启用的分类
export function getActiveCategories() {
  return request({
    url: '/category/active',
    method: 'get'
  })
}

// 获取分类详情
export function getCategoryDetail(id) {
  return request({
    url: `/category/${id}`,
    method: 'get'
  })
}

// 创建分类
export function createCategory(data) {
  return request({
    url: '/category',
    method: 'post',
    data
  })
}

// 更新分类
export function updateCategory(id, data) {
  return request({
    url: `/category/${id}`,
    method: 'put',
    data
  })
}

// 删除分类
export function deleteCategory(id) {
  return request({
    url: `/category/${id}`,
    method: 'delete'
  })
}

// 更新分类状态
export function updateCategoryStatus(id, status) {
  return request({
    url: `/category/${id}/status`,
    method: 'put',
    params: { status }
  })
}

